<?php $this->load->view('common/header');?>

<body>
<?php $this->load->view('common/user_center');?>
<div class="main_box">
    <?php $this->load->view('common/menu');?>
    <div class="right_box f_r">
        <div class="title">
        	<span class="f_l">个人资料</span>
        </div>
        <div class="ifrom_list">
            <dl>
            	<dt>头像：</dt>
                <dd>
                	<a href="javascript:;" class="head avatar_pic">
                    	<input type="file">
                        <div id="avatar-box">
                            <?php if(!empty($user['avatar'])){ ?>
                                <img src="<?php echo $user['avatar'];?>">
                            <?php }else{ ?>
                                <img src="<?php echo $viewmulu;?>images/defeat_photo.png">
                            <?php } ?>
                        </div>
                    </a>
                </dd>
            </dl>
            <dl>
            	<dt>昵称：</dt>
                <dd>
                	<span class="input">
                    	<input placeholder="请输入昵称" id="user_name" name="user_name" value="<?php echo $user['user_uname']; ?>">
                    </span>
                </dd>
            </dl>
            <dl>
            	<dt>手机号码：</dt>
                <dd>
                	<span class="tips">
                    	<?php echo $user['user_tel']; ?>
                    </span>
                </dd>
            </dl>
            <dl>
            	<dt>公司名称：</dt>
                <dd>
                	<span class="input">
                    	<input placeholder="请输入公司名称" id="user_company" name="user_company" value="<?php echo $user['user_company']; ?>">
                    </span>
                </dd>
            </dl>
            <dl>
            	<dt>登录密码：</dt>
                <dd>
                	<span class="input">
                    	<input placeholder="请输入新的登录密码,留空不更改" id="user_password" name="user_password">
                    </span>
                </dd>
            </dl>
            <dl>
            	<dt>&nbsp;</dt>
                <dd>
                	<a href="javascript:;" class="nav do-edit">确定修改</a>
                </dd>
            </dl>
        </div>
    </div>
</div>
<!--]] user -->
<!-- coypright [[-->
<?php $this->load->view('common/footer');?>
<!--]] coypright -->
<script src="<?php echo $viewmulu;?>js/jquery.core.image.upload.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var uid = "<?php echo $user['user_id'];?>";
        $(".avatar_pic").coreImageUpload ({
            url: baseurl + 'index.php/upload/upload_avatar?uid=' + uid+'&name='+uid+"_avatar",
            inputOfFile: 'avatar_pic',
            uploadedCallback: function (result) {
                if (result.status == 1) {
                    var img = '<img src="' + result.url + '">';
                    $("#avatar-box").html(img);
                    layer.msg("头像上传成功");
                } else {
                    layer.msg(result.msg, {offset: "80px"});
                }
            }
        });

        // 提交
        $(".do-edit").on("click",function(){

            var user_name = $("#user_name").val();
            var user_company = $("#user_company").val();
            var user_password = $("#user_password").val();
            var URL= baseurl+"index.php/vip/user/member";
            $.ajax({
                type: "post",
                url: URL,
                dataType:'json',
                data: {
                    'user_name':user_name,
                    'user_company':user_company,
                    'user_password':user_password,
                    'csrf_test_name': ci_csrf_token()
                },
                success: function(data){
                    if(data.status == 200){
                        layer.msg('修改成功', {
                            time: 1000, //1s后自动关闭
                            shade: 0.1
                        },function () {
                            window.location.href = window.location.href;
                        });
                    }else{
                        layer.msg(data.msg);
                        return false;
                    }

                }
            });
        });
    });
</script>
</body>
</html>
